package com.ruoyi.lendmoney.controller;

import com.ruoyi.lendmoney.domain.Bill;
import com.ruoyi.lendmoney.domain.LoanPersonTable;
import com.ruoyi.lendmoney.domain.Results;
import com.ruoyi.lendmoney.service.LoanPersonTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;

@RestController
@RequestMapping("api/lendmoney")
public class LoanPersonTableController {
    @Autowired
    private LoanPersonTableService loanPersonTableService;

    @RequestMapping("addLoanper")
    public Results addLoanper(@RequestBody LoanPersonTable loanPersonTable){
        return loanPersonTableService.add(loanPersonTable);
    }

    @RequestMapping("getBill")
    public Results getBill(Integer type, BigDecimal price){
        ArrayList<Bill> bills = new ArrayList<>();
        for (Integer i = 0; i < type; i++) {
            Bill bill = new Bill();
            bill.setTimes(LocalDate.now().plusMonths(i+1));
            bill.setPrice(price);
            bills.add(bill);
        }
        return new Results(200,"",bills);
    }
}
